class Solution {
public:
    vector<string> summaryRanges(vector<int>& nums) {
        vector<string> ret;
        int i = 0;
        int n = nums.size();
        while (i < n)
        {
            int low = i;
            i++;
            while (i < n && nums[i] == nums[i - 1] + 1)
            {
                i++;
            }
            int high = i - 1;
            string tmp = to_string(nums[low]);
            if (low < high)
            {
                tmp.append("->");
                tmp.append(to_string(nums[high]));
            }
            ret.push_back(tmp);
        }
        return ret;
    }
};